home *** CD-ROM | disk | FTP | other *** search
/ Amiga CD-Sensation: Golden Games / Amiga CD-Sensation - Ausgabe 2 - Golden Games (1996)(GTI - Schatztruhe)(DE)[!].iso / Brain Activity / Rubik / source / extras.c < prev    next >
C/C++ Source or Header  |  1990-08-11  |  5KB  |  257 lines

  1. /*    bits and pieces for rubik.c        M.J.R.    4th Feb 90    */
  2.  
  3. extern struct Window *wnd1,*wnd2;
  4. extern struct Screen *scr1,*scr2;
  5. extern struct Gadget redplus;
  6. extern struct Gadget greenplus;
  7. extern struct Gadget blueplus;
  8. extern struct Gadget redminus;
  9. extern struct Gadget greenminus;
  10. extern struct Gadget blueminus;
  11. extern struct Gadget colour1;
  12. extern struct Gadget colour2;
  13. extern struct Gadget colour3;
  14. extern struct Gadget colour4;
  15. extern struct Gadget colour5;
  16. extern struct Gadget colour6;
  17. extern struct Gadget redplusa;
  18. extern struct Gadget greenplusa;
  19. extern struct Gadget blueplusa;
  20. extern struct Gadget redminusa;
  21. extern struct Gadget greenminusa;
  22. extern struct Gadget blueminusa;
  23. extern struct Gadget colour1a;
  24. extern struct Gadget colour2a;
  25. extern struct Gadget colour3a;
  26. extern struct Gadget colour4a;
  27. extern struct Gadget colour5a;
  28. extern struct Gadget colour6a;
  29.  
  30. void getcolours(int pen, int *red, int *green, int *blue)
  31.     {
  32.     struct ViewPort *vp;
  33.     UWORD colour;
  34.     
  35.     vp = ViewPortAddress(wnd1);
  36.     
  37.     colour = GetRGB4(vp->ColorMap,pen);
  38.     
  39.     *blue = colour & 0x00f;
  40.     *green = (colour & 0x0f0) >> 4;
  41.     *red = (colour & 0xf00) >> 8;
  42.     }
  43.     
  44. void showcolours (int red, int green, int blue)
  45.     {
  46.     char buffer[7];
  47.     
  48.     sprintf(buffer,"%02d%02d%02d",red,green,blue);
  49.  
  50.     SetAPen(wnd1->RPort,7);
  51.     SetBPen(wnd1->RPort,0);
  52.     SetDrMd(wnd1->RPort,JAM2);
  53.  
  54.     Move(wnd1->RPort,249,184);
  55.     Text(wnd1->RPort,buffer,2);
  56.     Move(wnd1->RPort,273,184);
  57.     Text(wnd1->RPort,&(buffer[2]),2);
  58.     Move(wnd1->RPort,297,184);
  59.     Text(wnd1->RPort,&(buffer[4]),2);
  60.  
  61.     ClipBlit
  62.         (
  63.         wnd1->RPort,243,157,
  64.         wnd2->RPort,243,157,
  65.         75,41,
  66.         0xc0
  67.         );
  68.     }
  69.  
  70. void modcolours (int pen, int colour, int change)
  71.     {
  72.     int primary[3];
  73.     
  74.     getcolours(pen,&(primary[0]),&(primary[1]),&(primary[2]));
  75.     
  76.     if ((((primary[colour]) += change) > 15) || ((primary[colour]) < 0))
  77.         (primary[colour]) -= change;
  78.     
  79.     SetRGB4(&(scr1->ViewPort),pen,primary[0],primary[1],primary[2]);
  80.     SetRGB4(&(scr2->ViewPort),pen,primary[0],primary[1],primary[2]);
  81.     
  82.     showcolours(primary[0],primary[1],primary[2]);
  83.     }
  84.  
  85. void selectpen (int pen)
  86.     {
  87.     int i,j,red,green,blue;
  88.     
  89.     SetAPen(wnd1->RPort,0);
  90.     SetDrMd(wnd1->RPort,JAM1);
  91.     
  92.     for (i=0; i<4; i++)
  93.         {
  94.         Move(wnd1->RPort,202+10*i,165);
  95.         Draw(wnd1->RPort,202+10*i,185);
  96.         }
  97.  
  98.     for (i=0; i<3; i++)
  99.         {
  100.         Move(wnd1->RPort,202,165+10*i);
  101.         Draw(wnd1->RPort,232,165+10*i);
  102.         }
  103.  
  104.     SetAPen(wnd1->RPort,7);
  105.  
  106.     
  107.     if (pen > 3)
  108.         {
  109.         i = 162+10*pen;
  110.         j = 175;
  111.         }
  112.     else
  113.         {
  114.         i = 192+10*pen;
  115.         j = 165;
  116.         }
  117.     
  118.     Move (wnd1->RPort,i,j);
  119.     Draw (wnd1->RPort,i+10,j);
  120.     Draw (wnd1->RPort,i+10,j+10);
  121.     Draw (wnd1->RPort,i,j+10);
  122.     Draw (wnd1->RPort,i,j);
  123.     
  124.     ClipBlit
  125.         (
  126.         wnd1->RPort,201,164,
  127.         wnd2->RPort,201,164,
  128.         32,22,
  129.         0xc0
  130.         );
  131.     
  132.     getcolours(pen,&red,&green,&blue);
  133.     showcolours(red,green,blue);
  134.     }
  135.  
  136. void addpaints()
  137.     {
  138.     int i;
  139.     
  140.     AddGadget(wnd1,&redplus,-1);
  141.     AddGadget(wnd1,&greenplus,-1);
  142.     AddGadget(wnd1,&blueplus,-1);
  143.     AddGadget(wnd1,&redminus,-1);
  144.     AddGadget(wnd1,&greenminus,-1);
  145.     AddGadget(wnd1,&blueminus,-1);
  146.     AddGadget(wnd1,&colour1,-1);
  147.     AddGadget(wnd1,&colour2,-1);
  148.     AddGadget(wnd1,&colour3,-1);
  149.     AddGadget(wnd1,&colour4,-1);
  150.     AddGadget(wnd1,&colour5,-1);
  151.     AddGadget(wnd1,&colour6,-1);
  152.  
  153.     AddGadget(wnd2,&redplusa,-1);
  154.     AddGadget(wnd2,&greenplusa,-1);
  155.     AddGadget(wnd2,&blueplusa,-1);
  156.     AddGadget(wnd2,&redminusa,-1);
  157.     AddGadget(wnd2,&greenminusa,-1);
  158.     AddGadget(wnd2,&blueminusa,-1);
  159.     AddGadget(wnd2,&colour1a,-1);
  160.     AddGadget(wnd2,&colour2a,-1);
  161.     AddGadget(wnd2,&colour3a,-1);
  162.     AddGadget(wnd2,&colour4a,-1);
  163.     AddGadget(wnd2,&colour5a,-1);
  164.     AddGadget(wnd2,&colour6a,-1);
  165.     
  166.     SetAPen(wnd1->RPort,7);
  167.     SetDrMd(wnd1->RPort,JAM1);
  168.     
  169.     for (i=0; i<3; i++)
  170.         {
  171.         Move(wnd1->RPort,253+i*24,168);
  172.         Draw(wnd1->RPort,260+i*24,168);
  173.         Move(wnd1->RPort,253+i*24,186);
  174.         Draw(wnd1->RPort,260+i*24,186);
  175.         }
  176.     
  177.     Move(wnd1->RPort,200,163);
  178.     Draw(wnd1->RPort,234,163);
  179.     Draw(wnd1->RPort,234,187);
  180.     Draw(wnd1->RPort,200,187);
  181.     Draw(wnd1->RPort,200,163);
  182.  
  183.     for (i=0; i<4; i++)
  184.         {
  185.         Move(wnd1->RPort,244+24*i,158);
  186.         Draw(wnd1->RPort,244+24*i,195);
  187.         Draw(wnd1->RPort,245+24*i,195);
  188.         Draw(wnd1->RPort,245+24*i,158);
  189.         }
  190.  
  191.     for (i=0; i<2; i++)
  192.         {
  193.         Move(wnd1->RPort,244,157+39*i);
  194.         Draw(wnd1->RPort,317,157+39*i);
  195.         Draw(wnd1->RPort,317,158+39*i);
  196.         Draw(wnd1->RPort,244,158+39*i);
  197.         }
  198.     
  199.     Move(wnd1->RPort,253,166);
  200.     Text(wnd1->RPort,"R  G  B",7);
  201.     
  202.     ClipBlit
  203.         (
  204.         wnd1->RPort,190,150,
  205.         wnd2->RPort,190,150,
  206.         128,48,
  207.         0xc0
  208.         );
  209.                 
  210.     RefreshGadgets(&redplus,wnd1,NULL);
  211.     RefreshGadgets(&redplusa,wnd2,NULL);
  212.     
  213.     selectpen(1);
  214.     }
  215.  
  216.  
  217. void removepaints()
  218.     {
  219.     RemoveGadget(wnd1,&redplus);
  220.     RemoveGadget(wnd1,&greenplus);
  221.     RemoveGadget(wnd1,&blueplus);
  222.     RemoveGadget(wnd1,&redminus);
  223.     RemoveGadget(wnd1,&greenminus);
  224.     RemoveGadget(wnd1,&blueminus);
  225.     RemoveGadget(wnd1,&colour1);
  226.     RemoveGadget(wnd1,&colour2);
  227.     RemoveGadget(wnd1,&colour3);
  228.     RemoveGadget(wnd1,&colour4);
  229.     RemoveGadget(wnd1,&colour5);
  230.     RemoveGadget(wnd1,&colour6);
  231.  
  232.     RemoveGadget(wnd2,&redplusa);
  233.     RemoveGadget(wnd2,&greenplusa);
  234.     RemoveGadget(wnd2,&blueplusa);
  235.     RemoveGadget(wnd2,&redminusa);
  236.     RemoveGadget(wnd2,&greenminusa);
  237.     RemoveGadget(wnd2,&blueminusa);
  238.     RemoveGadget(wnd2,&colour1a);
  239.     RemoveGadget(wnd2,&colour2a);
  240.     RemoveGadget(wnd2,&colour3a);
  241.     RemoveGadget(wnd2,&colour4a);
  242.     RemoveGadget(wnd2,&colour5a);
  243.     RemoveGadget(wnd2,&colour6a);
  244.  
  245.     SetDrMd(wnd1->RPort,JAM1);
  246.     SetAPen(wnd1->RPort,0);
  247.     RectFill(wnd1->RPort,190,150,317,197);
  248.     
  249.     ClipBlit
  250.         (
  251.         wnd1->RPort,190,150,
  252.         wnd2->RPort,190,150,
  253.         128,48,
  254.         0xc0
  255.         );
  256.     }
  257.